//
//  MPMeCell.m
//  MobileProject
//
//  Created by caiqilin on 2016/11/15.
//  Copyright © 2016年 caiqilin. All rights reserved.
//

#import "MPMeCell.h"

@implementation MPMeCell
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    // 1.确定重用标示:
    static NSString *ID = @"me";
    
    // 2.从缓存池中取
    MPMeCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    // 3.如果空就手动创建
    if (!cell) {
        cell = [[MPMeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        self.textLabel.textColor = [UIColor darkGrayColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //        self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow"]];
        self.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainCellBackground"]];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    if (self.imageView.image == nil) return;
    
    // imageView
    self.imageView.ex_y = MPSmallMargin;
    self.imageView.ex_height = self.contentView.ex_height - 2 * MPSmallMargin;
    self.imageView.ex_width = self.imageView.ex_height;
    
    // label
    self.textLabel.ex_x = self.imageView.ex_right + MPMargin;
}

@end

